import React, { Component, PureComponent } from 'react'

export default class AddTask extends PureComponent {
  state = {
    name:''
  }
  hanldeAdd = e=>{
    this.setState({
      name:e.target.value
    })
  }
  handleBtn = ()=>{
    this.state.name && this.props.onAddTask && this.props.onAddTask(this.state.name)
            // this.state.name && this.setState({
            //   name:''
            // })
  }
  render() {
    console.log('addTask')
    return (
      <div>
        <input type='text' value={this.state.name} onChange={
         this.hanldeAdd
        }
        />
        <button onClick={
          this.handleBtn
        }>添加任务</button>
      </div>
    )
  }
}
